using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
    /// <summary>
    /// Controller class for NewsLog
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class NewsLogController
    {
        // Preload our schema..
        NewsLog thisSchemaLoad = new NewsLog();
        private string userName = string.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}

					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}

				}

				return userName;
            }

        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public NewsLogCollection FetchAll()
        {
            NewsLogCollection coll = new NewsLogCollection();
            Query qry = new Query(NewsLog.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public NewsLogCollection FetchByID(object NewsLogID)
        {
            NewsLogCollection coll = new NewsLogCollection().Where("NewsLogID", NewsLogID).Load();
            return coll;
        }

		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public NewsLogCollection FetchByQuery(Query qry)
        {
            NewsLogCollection coll = new NewsLogCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object NewsLogID)
        {
            return (NewsLog.Delete(NewsLogID) == 1);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object NewsLogID)
        {
            return (NewsLog.Destroy(NewsLogID) == 1);
        }

        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(byte? CountryID,DateTime RFDate,byte? MediaType,int? MediaCode,string NewsTitle,byte? NewsType,string NewsTypeName,int? PageNumber,int? ColumnSize,int? InchesSize,decimal? RealCost,int? SectionCode,int? ProductID,int? CategoryID,int? SubSectorID,int? SectorID,string NewsLink,string NewsMediaType,string CropPicture,string FullPagePicture,string PDFName,DateTime DateAdded,DateTime DateModified)
	    {
		    NewsLog item = new NewsLog();
		    
            item.CountryID = CountryID;
            
            item.RFDate = RFDate;
            
            item.MediaType = MediaType;
            
            item.MediaCode = MediaCode;
            
            item.NewsTitle = NewsTitle;
            
            item.NewsType = NewsType;
            
            item.NewsTypeName = NewsTypeName;
            
            item.PageNumber = PageNumber;
            
            item.ColumnSize = ColumnSize;
            
            item.InchesSize = InchesSize;
            
            item.RealCost = RealCost;
            
            item.SectionCode = SectionCode;
            
            item.ProductID = ProductID;
            
            item.CategoryID = CategoryID;
            
            item.SubSectorID = SubSectorID;
            
            item.SectorID = SectorID;
            
            item.NewsLink = NewsLink;
            
            item.NewsMediaType = NewsMediaType;
            
            item.CropPicture = CropPicture;
            
            item.FullPagePicture = FullPagePicture;
            
            item.PDFName = PDFName;
            
            item.DateAdded = DateAdded;
            
            item.DateModified = DateModified;
            
	    
		    item.Save(UserName);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int NewsLogID,byte? CountryID,DateTime RFDate,byte? MediaType,int? MediaCode,string NewsTitle,byte? NewsType,string NewsTypeName,int? PageNumber,int? ColumnSize,int? InchesSize,decimal? RealCost,int? SectionCode,int? ProductID,int? CategoryID,int? SubSectorID,int? SectorID,string NewsLink,string NewsMediaType,string CropPicture,string FullPagePicture,string PDFName,DateTime DateAdded,DateTime DateModified)
	    {
		    NewsLog item = new NewsLog();
		    
				item.NewsLogID = NewsLogID;
				
				item.CountryID = CountryID;
				
				item.RFDate = RFDate;
				
				item.MediaType = MediaType;
				
				item.MediaCode = MediaCode;
				
				item.NewsTitle = NewsTitle;
				
				item.NewsType = NewsType;
				
				item.NewsTypeName = NewsTypeName;
				
				item.PageNumber = PageNumber;
				
				item.ColumnSize = ColumnSize;
				
				item.InchesSize = InchesSize;
				
				item.RealCost = RealCost;
				
				item.SectionCode = SectionCode;
				
				item.ProductID = ProductID;
				
				item.CategoryID = CategoryID;
				
				item.SubSectorID = SubSectorID;
				
				item.SectorID = SectorID;
				
				item.NewsLink = NewsLink;
				
				item.NewsMediaType = NewsMediaType;
				
				item.CropPicture = CropPicture;
				
				item.FullPagePicture = FullPagePicture;
				
				item.PDFName = PDFName;
				
				item.DateAdded = DateAdded;
				
				item.DateModified = DateModified;
				
		    item.MarkOld();
		    item.Save(UserName);
	    }

    }

}

